import request from '@/utils/request'
// import qs from 'qs'

// 接口流量

// 流量统计
export function getFlowStatistics (params) {
  var data = fromData(params)
  return request({
    url: '/flow/getFlowStatistics',
    method: 'post',
    data
  })
}

// 获取转发柱状统计图数据
export function getForwarding (params) {
  var data = fromData(params)
  return request({
    url: '/flow/getForwarding',
    method: 'post',
    data
  })
}

// 流量统计

// 获取指定类型列表
export function getArray (params) {
  var data = fromData(params)
  return request({
    url: '/flow/getArray',
    method: 'post',
    data
  })
}

// 删除信息
export function delInfo (params) {
  var data = fromData(params)
  return request({
    url: '/flow/del_info',
    method: 'post',
    data
  })
}

// 增加信息
export function addInfo (params) {
  var data = fromData(params)
  return request({
    url: '/flow/addInfo',
    method: 'post',
    data
  })
}

// 修改信息
export function editInfo (params) {
  var data = fromData(params)
  return request({
    url: '/flow/editInfo',
    method: 'post',
    data
  })
}

// 查看信息
export function getInfo (params) {
  var data = fromData(params)
  return request({
    url: '/flow/getInfo',
    method: 'post',
    data
  })
}

// 重新统计
export function reChear (params) {
  var data = fromData(params)
  return request({
    url: '/flow/chear',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
